<%@ page language="java" import="java.util.*,com.example.filemanagement.*" pageEncoding="utf-8"%>
<html>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    //学生
    if(request.getParameter("UserName")!=null) {
      String UserName0 = request.getParameter("UserName");
      String PassWord0 = request.getParameter("PassWord");
      int LoginUserResult0 = Connect.LoginUser(UserName0, PassWord0);
      if (LoginUserResult0 == -1) {
        request.setAttribute("msg", "密码不能为空！");
        request.getRequestDispatcher("loginForm.jsp").forward(request, response);
      }
      if (LoginUserResult0 == 0) {
        //登录成功
        session.setAttribute("LoginedUserName", request.getParameter("UserName"));
        request.getRequestDispatcher("index.jsp").forward(request, response);
      } else if (LoginUserResult0 == 1) {
        request.setAttribute("msg", "学号错误！");
        request.getRequestDispatcher("loginForm.jsp").forward(request, response);
      } else if (LoginUserResult0 == 2) {
        request.setAttribute("msg", "密码错误！");
        request.getRequestDispatcher("loginForm.jsp").forward(request, response);
      }
    }
//管理员
  if(request.getParameter("ManagementName")!=null) {
    String UserName2 = request.getParameter("ManagementName");
    String PassWord2 = request.getParameter("ManagementPassWord");
    int LoginUserResult2 = Connect.LoginManagement(UserName2, PassWord2);
    if (LoginUserResult2 == -1) {
      request.setAttribute("msg", "密码不能为空！");
      request.getRequestDispatcher("ManageForm.jsp").forward(request, response);
    }
    if (LoginUserResult2 == 0) {
      //登录成功
      session.setAttribute("LoginedManagementName", request.getParameter("ManagementName"));
      request.getRequestDispatcher("index1.jsp").forward(request, response);
    } else if (LoginUserResult2 == 1) {
      request.setAttribute("msg", "账号错误！");
      request.getRequestDispatcher("ManageForm.jsp").forward(request, response);
    } else if (LoginUserResult2 == 2) {
      request.setAttribute("msg", "密码错误！");
      request.getRequestDispatcher("ManageForm.jsp").forward(request, response);
    }
  }
%>

</body>
</html>
